<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="renderer" content="webkit">
    <title>登录</title>
    <link href="static1/css/bootstrap.min-3.4.0.css" rel="stylesheet">
    <link href="static1/css/font-awesome-4.3.0.css" rel="stylesheet">
    <link href="static1/css/animate.css" rel="stylesheet">
    <link href="static1/css/style-2.2.0.css" rel="stylesheet">
    <link href="static1/css/index.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript"></script>
    <script>

		  // 核心业务逻辑
		  $(function(){
			  $("#submit").click(function(){
				  var username = $("#username").val();
				  var password = $("#password").val();

				  if(username.trim() == "" || password.trim() == "") {
					  alert("用户名或者密码不能为空！");
					  return;
				  }

				  $.ajax({
					  url:"/user/login",
					  data:{"username":username,"password":password},
					  type:"POST",
					  dataType:"json",
					  success:function(data) {
						  console.log(data);
						  if(data && data.userId <= 0){
							alert("登录失败，密码或者用户名错误！");
							$("#user").val("");
							$("#password").val("");
						  }else {
						      //存储token
                              localStorage.setItem("user_token", data.token);
						      alert("登录成功！");
							  window.location.href="index.html";
						  }
				      }
				  });
			  });
		  });
	  </script>
</head>

<body class="gray-bg">
    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div class="form-signin">
                <div class="form-group">
                    <input id="username" type="phone" class="form-control" placeholder="用户名">
                </div>
                <div class="form-group">
                    <input id="password" type="password" class="form-control" placeholder="密码">
                </div>
                
                <button id="submit" class="btn btn-primary block full-width m-b">登 录</button>
                <div class="form-group">
                    <div class="checkbox i-checks">
                        <span class="text-muted text-center"><a href="register.html">注册一个新账号</a>
                        </span>
                    </div>
                </div>
                <img src="static1/picture/1.gif" style="width: 100%;">

        </div>
    </div>

<!--    &lt;!&ndash; Mainly scripts &ndash;&gt;-->
<!--    <script src="static/js/jquery-2.1.1.min.js"></script>-->
<!--    <script src="static/js/bootstrap.min-3.4.0.js"></script>-->
<!--    <script type="text/javascript">-->
<!--        function stop() {-->
<!--            return false;-->
<!--        }-->
<!--        document.oncontextmenu = stop;-->
<!--    </script>-->
<!--    <script src="static/js/live2d.min.js"></script>-->
<!--    <script src="static/js/index.js"></script>-->
</body>

</html>
